/**
 * @description 二分排序算法
 * @description 仅用于对顺序数组进行搜索，此处假定对一个递增数组进行搜索
 * @param item
 */
Array.prototype.binarySearch = function (item){
    let low = 0;
    let high = this.length - 1;
    while (low < high){
        const mid = Math.floor((low+high)/2);
        const element = this[mid];
        if (element < item){
            low = mid + 1;
        }else if (element > item){
            high = mid - 1;
        }else {
            return mid;
        }
    }
    return -1;
};

//时间复杂度：O(log n)